#include "config.h"



const QChar Config::m_joker = '?';
const QChar Config::m_blankDisplay = ' ';


//-------------------------------------
const QString Config::officialRefDicosPath ()
{
	QStringList places;

	places << "/home/gilles/dev/mcroises";
	places << QCoreApplication::applicationDirPath ();
	places << "/usr/share/mcroises";
	places << "/opt/mcroises";

	foreach (const QString& testDir, places) {
		QString dicDir (testDir + "/dics/");
		if (QDir (QDir::toNativeSeparators(dicDir)).exists ())
			return dicDir;
	}

	return QString ();
}

//-----------------------------------------------
void Config::setCurrentRefDico (const QString &fileName)
{
	setValue ("currentRefDico", fileName);
}
//-------------------------------
QString Config::currentRefDico ()
{
	return value ("currentRefDico",
				  QString ("dico_%1.dic").arg (QLocale::system ().name ().left (2))
				  ).toString ();
}
//----------------------------------------------
void Config::setAlertOverWriteReference (bool b)
{
	setValue ("alertOverwriteReference", b);
}
//-------------------------------------
bool Config::alertOverwriteReference ()
{
	return value ("alertOverwriteReference", true).toBool ();
}
//----------------------------
bool Config::useDamerauTest ()
{
	return value ("useDamerauTest", true).toBool ();
}
//-------------------------------------
void Config::setUseDamerauTest (bool b)
{
	setValue ("useDamerauTest", b);
}
//----------------------------
bool Config::displayExecTime ()
{
	return value ("displayExecTime", true).toBool ();
}
//-------------------------------------
void Config::setDisplayExecTime (bool b)
{
	setValue ("displayExecTime", b);
}
//------------------------
int Config::letterCount()
{
	return value ("letterCount", 10).toInt ();
}
//------------------------------------
void Config::setLetterCount(int count)
{
	setValue ("letterCount", count);
}
